$(function() {
	fun();		
	setInterval(fun, 300000);
})
function fun() {
		$.ajax({
			type : 'post',
			url : ctx+'/engineer/messageInstationUser',
			success : function(data) {
				if(null!=data.mailNum){
					$("#mailNum").html(data.mailNum);
				
				if(data.mailNum!=0&&data.mailNum!=null&&data.mailNum!="")
				$("#mailNumMenu").html(data.mailNum);
				else
					$("#mailNumMenu").hide();
				
				if(data.mailNum!=0&&data.mailNum!=null&&data.mailNum!="")
					$("#mailMessageNumMenu").html(data.mailNum);	
				else
					$("#mailMessageNumMenu").hide();
				
				if(data.unconfirmedNum!=0&&data.unconfirmedNum!=null)
					$("#unconfirmedNum").html(data.unconfirmedNum);
				else
					$("#unconfirmedNum").hide();
				
				/*console.log(data.unconfirmedNum+":1")*/
				
				if(data.hungUpNum!=0&&data.hungUpNum!=null)
					$("#hungUpNum").html( data.hungUpNum);
				else
					$("#hungUpNum").hide();
				
				/*console.log(data.hungUpNum+":2")*/
				
				if(data.unsolvedNum!=0&&data.unsolvedNum!=null)
					$("#unsolvedNum").html(data.unsolvedNum);
				else
					$("#unsolvedNum").hide();
				
//				console.log(data.unsolvedNum+":3")
				
				if(data.submittedNum!=0&&data.submittedNum!=null)
					$("#submittedNum").html(data.submittedNum);
				else
					$("#submittedNum").hide();	
				
//				console.log(data.submittedNum+":4")
				
				if(data.finishNum!=0&&data.finishNum!=null){
					$("#finishNum").html(data.finishNum);
				}else
					$("#finishNum").hide();
				
//				console.log(data.finishNum+":5")
				
				if(data.gestUnconfirmedNum!=0&&data.gestUnconfirmedNum!=null)
					$("#gestUnconfirmedNum").html(data.gestUnconfirmedNum);
				else
					$("#gestUnconfirmedNum").hide();
				
//				console.log(data.gestUnconfirmedNum+":6")
				
				if(data.gestUnsolvedNum!=0&&data.gestUnsolvedNum!=null)
					$("#gestUnsolvedNum").html( data.gestUnsolvedNum);
				else
					$("#gestUnsolvedNum").hide();
				
//				console.log(data.gestUnsolvedNum+":7")
				
				if(data.gestFinishNum!=0&&data.gestFinishNum!=null)
					$("#gestFinishNum").html(data.gestFinishNum);
				else
					$("#gestFinishNum").hide();
				
//				console.log(data.gestFinishNum+":8")
				
				if(data.notDirectedNum!=0&&data.notDirectedNum!=null)
					$("#notDirectedNum").html(data.notDirectedNum);
				else
					$("#notDirectedNum").hide();
				
//				console.log(data.notDirectedNum+":9")
				
				if(data.waitEngHungUpNum!=0&&data.waitEngHungUpNum!=null){
					$("#engWaitHungUpNum").html(data.waitEngHungUpNum);
					}else{
					$("#engWaitHungUpNum").hide();
					}
				
//				console.log(data.waitEngHungUpNum+":10")
				
				if(data.waitManagerHungUpNum!=0&&data.waitManagerHungUpNum!=null){
					$("#manWaitHungUpNum").html(data.waitManagerHungUpNum);
					}else{
					$("#manWaitHungUpNum").hide();
					}
				
//				console.log(data.waitManagerHungUpNum+":11")
				
				if (data.crqReadyNum!=0&&data.crqReadyNum!=null) {
					$("#altReadyNum").html(data.crqReadyNum);
					$("#altNum").html(data.crqReadyNum);
				} else {
					$("#altReadyNum").hide();
					$("#altNum").hide();
				}
				
//				console.log(data.crqReadyNum+":11")
				
				if (data.cafReadyNum!=0&&data.cafReadyNum!=null) {
					$("#configReadyNum").html(data.cafReadyNum);
					$("#configNum").html(data.cafReadyNum);
				} else {
					$("#configReadyNum").hide();
					$("#configNum").hide();
				}
				
//				console.log(data.cafReadyNum+":12")
				
				if (data.pbiReadyNum!=0&&data.pbiReadyNum!=null) {
					$("#pbiReadyNum").html(data.pbiReadyNum);
					$("#pbiNum").html(data.pbiReadyNum);
				} else {
					$("#pbiReadyNum").hide();
					$("#pbiNum").hide();
				}
				
//				console.log(data.pbiReadyNum+":13")

				//-------case
				if(data.waitClosedCaseNum!=0&&data.waitClosedCaseNum!=null)
					$("#waitClosedCaseNum").html(data.waitClosedCaseNum);
				else
					$("#waitClosedCaseNum").hide();
				
//				console.log(data.waitClosedCaseNum+":14")
				
				if(data.waitExamineCaseNum!=0&&data.waitExamineCaseNum!=null)
					$("#waitExamineCaseNum").html(data.waitExamineCaseNum);
				else
					$("#waitExamineCaseNum").hide();
				
//				console.log(data.waitExamineCaseNum+":15")
				
				if(data.waitConfirmCaseNum!=0&&data.waitConfirmCaseNum!=null)
					$("#waitConfirmCaseNum").html(data.waitConfirmCaseNum);
				else
					$("#waitConfirmCaseNum").hide();
				
//				console.log(data.waitConfirmCaseNum+":16")
				
				if(data.waitDistributeCaseNum!=0&&data.waitDistributeCaseNum!=null)
					$("#waitDistributeCaseNum").html(data.waitDistributeCaseNum);
				else
					$("#waitDistributeCaseNum").hide();
				
//				console.log(data.waitDistributeCaseNum+":17")
				
				if(data.waitGrabCaseNum!=0&&data.waitGrabCaseNum!=null)
					$("#waitGrabCaseNum").html(data.waitGrabCaseNum);
				else
					$("#waitGrabCaseNum").hide();
				
//				console.log(data.waitGrabCaseNum+":18")
				
				if(data.waitHangCaseNum!=0&&data.waitHangCaseNum!=null)
					$("#waitHangCaseNum").html(data.waitHangCaseNum);
				else
					$("#waitHangCaseNum").hide();
				
//				console.log(data.waitHangCaseNum+":19")

				if(data.waitPendingCaseNum!=0&&data.waitPendingCaseNum!=null)
					$("#waitPendingCaseNum").html(data.waitPendingCaseNum);
				else
					$("#waitPendingCaseNum").hide();
				
//				console.log(data.waitPendingCaseNum+":20")
				
				//--------
				/*var unconfirmedNum=$("#unconfirmedNum").val();
				var hungUpNum=$("#hungUpNum").val();
				var unsolvedNum=$("#unsolvedNum").val();
				var submittedNum=$("#submittedNum").val();
				var finishNum=$("#finishNum").val();
				var gestUnconfirmedNum=$("#gestUnconfirmedNum").val();
				var gestFinishNum=$("#gestFinishNum").val();
				var gestUnsolvedNum = $("#gestUnsolvedNum").val();
				var notDirectedNum = $("#notDirectedNum").val();
				var manWaitHungUpNum = $("#manWaitHungUpNum").val();
				var engWaitHungUpNum = $("#engWaitHungUpNum").val();
				//-------case
				var waitClosedCaseNum = $("#waitClosedCaseNum").val();//待关闭
				var waitExamineCaseNum = $("#waitExamineCaseNum").val();//待审核
				var waitConfirmCaseNum = $("#waitConfirmCaseNum").val();//待确认
				var waitDistributeCaseNum = $("#waitDistributeCaseNum").val();//待派发
				var waitGrabCaseNum = $("#waitGrabCaseNum").val();//已抢单
				var waitHangCaseNum = $("#waitHangCaseNum").val();//待挂起
				var waitPendingCaseNum = $("#waitPendingCaseNum").val();//可抢工单
*/				//-------
				
				
//				var alt_ready_num = 
				var	OrderNum=0;
				var	ManagerNum=0;
				var CaseManagerNum = 0;
				
				if(data.unconfirmedNum!=null){
					
					OrderNum+=data.unconfirmedNum;
				}
				
				if(data.hungUpNum!=null){
					OrderNum+=data.hungUpNum;
				}
				
				if(data.waitEngHungUpNum!=null){
					OrderNum+=data.waitEngHungUpNum;
				}
				
					
				
				if(data.unsolvedNum!=null){
					OrderNum+=data.unsolvedNum;
				}
				
				if(data.waitHangCaseNum!=0&&data.waitHangCaseNum!=null){
					OrderNum+=data.waitHangCaseNum;
				}
					
				
				if(data.submittedNum!=null){
					ManagerNum+=data.submittedNum;
				}
					
				
				if(data.finishNum!=null){
					ManagerNum+=data.finishNum;
				}
					
				
				if(data.gestUnconfirmedNum!=null){
					OrderNum+=data.gestUnconfirmedNum;
				}
					
				
				if(data.gestFinishNum!=null){
					OrderNum+=data.gestFinishNum;
				}
					
				
				if(data.notDirectedNum!=null){
					ManagerNum+= data.notDirectedNum;
					
				}
					
				
				if(data.gestUnsolvedNum!=null){
					OrderNum+=data.gestUnsolvedNum;
				}
					
				
				if(data.waitHungUpNum!=null){
					ManagerNum+=data.waitHungUpNum;
				}
					
				
				if(data.waitHungUpNum!=null){
					OrderNum+=data.waitHungUpNum;
				}
					
				
				//Case单计数
				//服务台待关闭
				if(data.waitClosedCaseNum!=null)
					CaseManagerNum+=data.waitClosedCaseNum;
				
				if(data.waitExamineCaseNum!=null)
					CaseManagerNum+=data.waitExamineCaseNum;
				
				if(data.waitConfirmCaseNum!=null)
				CaseManagerNum+=data.waitConfirmCaseNum;
				
				if(data.waitDistributeCaseNum!=null)
					CaseManagerNum+=data.waitDistributeCaseNum;
				
				if(data.waitGrabCaseNum!=null)
					CaseManagerNum+=data.waitGrabCaseNum;
				
				if(data.waitHangCaseNum!=null)
					CaseManagerNum+=data.waitHangCaseNum;
				
				if(data.waitPendingCaseNum!=null)
					OrderNum+=data.waitPendingCaseNum;
				
				//----------
				
					if(OrderNum!=0&&OrderNum!=null)
						$("#OrderNum").html(OrderNum);
					else
						$("#OrderNum").hide();
					
					if(ManagerNum!=0&&ManagerNum!=null)
						
						$("#ManagerNum").html(ManagerNum);
					else
						$("#ManagerNum").hide();
					
					if(CaseManagerNum!=0&&CaseManagerNum!=null)
						$("#CaseManagerNum").html(CaseManagerNum);
					else
						$("#CaseManagerNum").hide();
					
					
				}
			}
		})
	}	